package com.ashlikun.frame.simple.wheel.adapter;

import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.ashlikun.frame.simple.R;

import java.util.List;

public class TestAdapter extends RecyclerView.Adapter<UserViewHolder> {

    private final List<UserBean> userBeanList;
    public int currentSelect = -1;

    public TestAdapter(List<UserBean> userBeanList) {
        this.userBeanList = userBeanList;
    }

    @Override
    public int getItemCount() {
        return userBeanList.size();
    }

    @Override
    public UserViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new UserViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.wheelview_item, null, false));
    }

    @Override
    public void onBindViewHolder(UserViewHolder holder, int position) {
        Log.e("wwww", "onBindViewHolder " + position + "  currentSelect = " + currentSelect);
        UserBean userBean = userBeanList.get(position);
        holder.iv_head.setImageResource(userBean.drawable);
        holder.tv_name.setText(userBean.name);
        if (currentSelect == position) {
            holder.tv_name.setTextColor(Color.RED);
        } else {
            holder.tv_name.setTextColor(Color.BLACK);
        }
    }

}
